﻿using System;
using System.Collections.Generic;
using System.Text;
using HostTool.Util;

namespace HostTool.Core
{
    /// <summary>
    /// 连接板
    /// </summary>
    class BoardLink:Board
    {

        public BoardLink(HostMachine machine)
            : base(machine)
        {
            CPU cpu = new LinkBoardCPU(this, 0x50, "板载CPU");
            AddCPU(cpu);
        }

        public override string Name
        {
            get
            {
                return "连接板";
            }
        }

    }

    public class LinkBoardCPU : CPU
    {

        string name = "";
        byte addr = 0;
        public LinkBoardCPU(IBoard board, byte addr, string name)
            : base(board, 0x0ab0, 0x0ab2)
        {
            this.name = name;
            this.addr = addr;
            //包含2个电压通道
            IniDocument config = this.Board.Machine.ConfigDoc;

            //包含26个电压通道+温度通道
            for (int i = 0; i <5; i++)
            {
                string channelName = "电压通道" + i;
                if (config != null)
                {
                    string config_name = config.GetString("连接板CPU通道", "通道" + i);
                    if (!string.IsNullOrEmpty(config_name))
                    {
                        channelName = config_name;
                    }

                }
                listChannel.Add(new CPUChannel(channelName, i));
            }


            AddFirmware(new FirmwareType("连接板APP", 0x16));
            AddFirmware(new FirmwareType("连接板BIOS", 0x51));
        }


        public override string Name
        {
            get
            {
                return this.name;
            }
        }

        public override byte DstPort
        {
            get
            {
                return addr;
            }
        }


    }
}
